package com.fileshare.web.dto.Vo;

import com.fileshare.web.entity.Authority;
import com.fileshare.web.entity.Role;
import lombok.*;
import org.springframework.beans.BeanUtils;

import java.util.List;
import java.util.stream.Collectors;

@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class AuthorityVo {

    private String authorityName;

    public static AuthorityVo fromEntity(Authority authority) {
        AuthorityVo roleVo = new AuthorityVo();
        BeanUtils.copyProperties(authority, roleVo);
        return roleVo;
    }

    public static List<AuthorityVo> fromEntities(List<Authority> authorities) {
        return authorities.stream().map(AuthorityVo::fromEntity).collect(Collectors.toList());
    }

}
